package com.itheima.pojo;

import lombok.Data;

@Data
public class Result {
    private Integer code;
    private String msg;
    private Object data;

    private Result(Integer code, String msg, Object data) {
        this.code = code;
        this.msg = msg;
        this.data = data;
    }

    /**
     * 默认成功方法
     */
    public static Result success() {
        return new Result(1, "success", null);
    }

    /**
     * 携带自定义成功信息的返回方法
     */
    public static Result success(String msg) {
        return new Result(1, msg, null);
    }

    public static Result success(String msg, Object data) {
        return new Result(1, msg, data);
    }

    /**
     * 携带数据的成功方法
     */
    public static Result success(Object object) {
        return new Result(1, "success", object);
    }
    //TODO 完成另外三个对应失败的

    /**
     * 默认失败方法
     */
    public static Result fail() {
        return new Result(0, "fail", null);
    }

    /**
     * 携带自定义成功信息的返回方法
     */
    public static Result fail(String msg) {
        return new Result(0, msg, null);
    }
    public static Result fail(String msg, Object data) {
        return new Result(0, msg, data);
    }

    /**
     * 携带数据的成功方法
     */
    public static Result fail(Object object) {
        return new Result(0, "fail", object);
    }
}
